print "input paramater @ARGV\n";
die;
$input_phasefile = $ARGV[0];
chomp($input_phasefile);
if($input_phasefile =~ m/gz$/)
{
	open(BUFF,"gunzip -c $input_phasefile|") or die "no $input_phasefile found\n";
}
else
{
	 open(BUFF,"$input_phasefile") or die "no $input_phasefile found\n";
}

#plink input file
$input_plink = $ARGV[1];
chomp($input_plink);
if($input_plink =~ m/\.tped\.gz$/)
{
	print "sucess $input_plink.tped\n";
	open(TPED,"gunzip -c $input_plink.tped.gz |") or die "no $input_plink.tped found\n";
}
else
{
	open(TPED,"$input_plink.tped" or die "no $input_plink.tped found\n";
}

#new file
$new_file = $ARGV[2];
chomp($new_file);
open(WRBUFF,">$new_file.tped") or die "not able to write file\n";
$line=<BUFF>;
$line=<BUFF>;
while(<BUFF>)
{
	chomp($_);
	$snp = <TPED>;
	chomp($snp);
	@snp = split(" ",$snp);
	@all = split(" ",$_);
	shift(@all);
	$rs1 = shift(@all);
	$l = join(" ",@all);
	if($rs1 eq $snp[1])
	{
		print WRBUFF "$snp[0] $snp[1] $snp[2] $snp[3] $l\n";
	}	
}
